3.1.11 \(\int \cot (c+d x) (a+b \tan (c+d x))^2 (B \tan (c+d x)+C \tan ^2(c+d x)) \, dx\) [11]

Optimal. Leaf size=87 \[ \left (a^2 B-b^2 B-2 a b C\right ) x-\frac {\left (2 a b B+a^2 C-b^2 C\right ) \log (\cos (c+d x))}{d}+\frac {b (b B+a C) \tan (c+d x)}{d}+\frac {C (a+b \tan (c+d x))^2}{2 d} \]

[Out]

(B*a^2-B*b^2-2*C*a*b)*x-(2*B*a*b+C*a^2-C*b^2)*ln(cos(d*x+c))/d+b*(B*b+C*a)*tan(d*x+c)/d+1/2*C*(a+b*tan(d*x+c))
^2/d

________________________________________________________________________________________

Rubi [A]
time = 0.10, antiderivative size = 87, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 38, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.105, Rules used = {3713, 3609, 3606, 3556} \begin {gather*} -\frac {\left (a^2 C+2 a b B-b^2 C\right ) \log (\cos (c+d x))}{d}+x \left (a^2 B-2 a b C-b^2 B\right )+\frac {b (a C+b B) \tan (c+d x)}{d}+\frac {C (a+b \tan (c+d x))^2}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Cot[c + d*x]*(a + b*Tan[c + d*x])^2*(B*Tan[c + d*x] + C*Tan[c + d*x]^2),x]

[Out]

(a^2*B - b^2*B - 2*a*b*C)*x - ((2*a*b*B + a^2*C - b^2*C)*Log[Cos[c + d*x]])/d + (b*(b*B + a*C)*Tan[c + d*x])/d
 + (C*(a + b*Tan[c + d*x])^2)/(2*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3606

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c - b
*d)*x, x] + (Dist[b*c + a*d, Int[Tan[e + f*x], x], x] + Simp[b*d*(Tan[e + f*x]/f), x]) /; FreeQ[{a, b, c, d, e
, f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]

Rule 3609

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*
((a + b*Tan[e + f*x])^m/(f*m)), x] + Int[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x
], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && GtQ[m, 0]

Rule 3713

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_.)*((A_.) + (B_.)
*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[1/b^2, Int[(a + b*Tan[e + f*x])
^(m + 1)*(c + d*Tan[e + f*x])^n*(b*B - a*C + b*C*Tan[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, A, B, C, m,
 n}, x] && NeQ[b*c - a*d, 0] && EqQ[A*b^2 - a*b*B + a^2*C, 0]

Rubi steps

\begin {align*} \int \cot (c+d x) (a+b \tan (c+d x))^2 \left (B \tan (c+d x)+C \tan ^2(c+d x)\right ) \, dx &=\int (a+b \tan (c+d x))^2 (B+C \tan (c+d x)) \, dx\\ &=\frac {C (a+b \tan (c+d x))^2}{2 d}+\int (a+b \tan (c+d x)) (a B-b C+(b B+a C) \tan (c+d x)) \, dx\\ &=\left (a^2 B-b^2 B-2 a b C\right ) x+\frac {b (b B+a C) \tan (c+d x)}{d}+\frac {C (a+b \tan (c+d x))^2}{2 d}+\left (2 a b B+a^2 C-b^2 C\right ) \int \tan (c+d x) \, dx\\ &=\left (a^2 B-b^2 B-2 a b C\right ) x-\frac {\left (2 a b B+a^2 C-b^2 C\right ) \log (\cos (c+d x))}{d}+\frac {b (b B+a C) \tan (c+d x)}{d}+\frac {C (a+b \tan (c+d x))^2}{2 d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [C] Result contains complex when optimal does not.
time = 0.32, size = 96, normalized size = 1.10 \begin {gather*} \frac {(a+i b)^2 (-i B+C) \log (i-\tan (c+d x))+(a-i b)^2 (i B+C) \log (i+\tan (c+d x))+2 b (b B+2 a C) \tan (c+d x)+b^2 C \tan ^2(c+d x)}{2 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Cot[c + d*x]*(a + b*Tan[c + d*x])^2*(B*Tan[c + d*x] + C*Tan[c + d*x]^2),x]

[Out]

((a + I*b)^2*((-I)*B + C)*Log[I - Tan[c + d*x]] + (a - I*b)^2*(I*B + C)*Log[I + Tan[c + d*x]] + 2*b*(b*B + 2*a
*C)*Tan[c + d*x] + b^2*C*Tan[c + d*x]^2)/(2*d)

________________________________________________________________________________________

Maple [A]
time = 0.31, size = 102, normalized size = 1.17

method result size
norman \(\left (a^{2} B -b^{2} B -2 C a b \right ) x +\frac {b \left (B b +2 C a \right ) \tan \left (d x +c \right )}{d}+\frac {b^{2} C \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {\left (2 B a b +C \,a^{2}-b^{2} C \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d}\) \(90\)
derivativedivides \(\frac {b^{2} B \left (\tan \left (d x +c \right )-d x -c \right )+b^{2} C \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}+\ln \left (\cos \left (d x +c \right )\right )\right )-2 B a b \ln \left (\cos \left (d x +c \right )\right )+2 C a b \left (\tan \left (d x +c \right )-d x -c \right )+a^{2} B \left (d x +c \right )-C \,a^{2} \ln \left (\cos \left (d x +c \right )\right )}{d}\) \(102\)
default \(\frac {b^{2} B \left (\tan \left (d x +c \right )-d x -c \right )+b^{2} C \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}+\ln \left (\cos \left (d x +c \right )\right )\right )-2 B a b \ln \left (\cos \left (d x +c \right )\right )+2 C a b \left (\tan \left (d x +c \right )-d x -c \right )+a^{2} B \left (d x +c \right )-C \,a^{2} \ln \left (\cos \left (d x +c \right )\right )}{d}\) \(102\)
risch \(B \,a^{2} x -B \,b^{2} x -2 C a b x +\frac {2 i b \left (-i C b \,{\mathrm e}^{2 i \left (d x +c \right )}+B b \,{\mathrm e}^{2 i \left (d x +c \right )}+2 C a \,{\mathrm e}^{2 i \left (d x +c \right )}+B b +2 C a \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}-\frac {2 i C \,b^{2} c}{d}-i C \,b^{2} x +2 i B a b x +\frac {2 i C \,a^{2} c}{d}+\frac {4 i B a b c}{d}+i C \,a^{2} x -\frac {2 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B a b}{d}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) C \,a^{2}}{d}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) b^{2} C}{d}\) \(204\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cot(d*x+c)*(a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x,method=_RETURNVERBOSE)

[Out]

1/d*(b^2*B*(tan(d*x+c)-d*x-c)+b^2*C*(1/2*tan(d*x+c)^2+ln(cos(d*x+c)))-2*B*a*b*ln(cos(d*x+c))+2*C*a*b*(tan(d*x+
c)-d*x-c)+a^2*B*(d*x+c)-C*a^2*ln(cos(d*x+c)))

________________________________________________________________________________________

Maxima [A]
time = 0.49, size = 91, normalized size = 1.05 \begin {gather*} \frac {C b^{2} \tan \left (d x + c\right )^{2} + 2 \, {\left (B a^{2} - 2 \, C a b - B b^{2}\right )} {\left (d x + c\right )} + {\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 2 \, {\left (2 \, C a b + B b^{2}\right )} \tan \left (d x + c\right )}{2 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)*(a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="maxima")

[Out]

1/2*(C*b^2*tan(d*x + c)^2 + 2*(B*a^2 - 2*C*a*b - B*b^2)*(d*x + c) + (C*a^2 + 2*B*a*b - C*b^2)*log(tan(d*x + c)
^2 + 1) + 2*(2*C*a*b + B*b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Fricas [A]
time = 1.42, size = 91, normalized size = 1.05 \begin {gather*} \frac {C b^{2} \tan \left (d x + c\right )^{2} + 2 \, {\left (B a^{2} - 2 \, C a b - B b^{2}\right )} d x - {\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 2 \, {\left (2 \, C a b + B b^{2}\right )} \tan \left (d x + c\right )}{2 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)*(a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="fricas")

[Out]

1/2*(C*b^2*tan(d*x + c)^2 + 2*(B*a^2 - 2*C*a*b - B*b^2)*d*x - (C*a^2 + 2*B*a*b - C*b^2)*log(1/(tan(d*x + c)^2
+ 1)) + 2*(2*C*a*b + B*b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Sympy [A]
time = 0.56, size = 151, normalized size = 1.74 \begin {gather*} \begin {cases} B a^{2} x + \frac {B a b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{d} - B b^{2} x + \frac {B b^{2} \tan {\left (c + d x \right )}}{d} + \frac {C a^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 2 C a b x + \frac {2 C a b \tan {\left (c + d x \right )}}{d} - \frac {C b^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {C b^{2} \tan ^{2}{\left (c + d x \right )}}{2 d} & \text {for}\: d \neq 0 \\x \left (a + b \tan {\left (c \right )}\right )^{2} \left (B \tan {\left (c \right )} + C \tan ^{2}{\left (c \right )}\right ) \cot {\left (c \right )} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)*(a+b*tan(d*x+c))**2*(B*tan(d*x+c)+C*tan(d*x+c)**2),x)

[Out]

Piecewise((B*a**2*x + B*a*b*log(tan(c + d*x)**2 + 1)/d - B*b**2*x + B*b**2*tan(c + d*x)/d + C*a**2*log(tan(c +
 d*x)**2 + 1)/(2*d) - 2*C*a*b*x + 2*C*a*b*tan(c + d*x)/d - C*b**2*log(tan(c + d*x)**2 + 1)/(2*d) + C*b**2*tan(
c + d*x)**2/(2*d), Ne(d, 0)), (x*(a + b*tan(c))**2*(B*tan(c) + C*tan(c)**2)*cot(c), True))

________________________________________________________________________________________

Giac [A]
time = 1.15, size = 95, normalized size = 1.09 \begin {gather*} \frac {C b^{2} \tan \left (d x + c\right )^{2} + 4 \, C a b \tan \left (d x + c\right ) + 2 \, B b^{2} \tan \left (d x + c\right ) + 2 \, {\left (B a^{2} - 2 \, C a b - B b^{2}\right )} {\left (d x + c\right )} + {\left (C a^{2} + 2 \, B a b - C b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{2 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(cot(d*x+c)*(a+b*tan(d*x+c))^2*(B*tan(d*x+c)+C*tan(d*x+c)^2),x, algorithm="giac")

[Out]

1/2*(C*b^2*tan(d*x + c)^2 + 4*C*a*b*tan(d*x + c) + 2*B*b^2*tan(d*x + c) + 2*(B*a^2 - 2*C*a*b - B*b^2)*(d*x + c
) + (C*a^2 + 2*B*a*b - C*b^2)*log(tan(d*x + c)^2 + 1))/d

________________________________________________________________________________________

Mupad [B]
time = 8.85, size = 91, normalized size = 1.05 \begin {gather*} \frac {\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )\,\left (\frac {C\,a^2}{2}+B\,a\,b-\frac {C\,b^2}{2}\right )}{d}-x\,\left (-B\,a^2+2\,C\,a\,b+B\,b^2\right )+\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (B\,b^2+2\,C\,a\,b\right )}{d}+\frac {C\,b^2\,{\mathrm {tan}\left (c+d\,x\right )}^2}{2\,d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(cot(c + d*x)*(B*tan(c + d*x) + C*tan(c + d*x)^2)*(a + b*tan(c + d*x))^2,x)

[Out]

(log(tan(c + d*x)^2 + 1)*((C*a^2)/2 - (C*b^2)/2 + B*a*b))/d - x*(B*b^2 - B*a^2 + 2*C*a*b) + (tan(c + d*x)*(B*b
^2 + 2*C*a*b))/d + (C*b^2*tan(c + d*x)^2)/(2*d)

________________________________________________________________________________________